<?php
namespace app\cxapi\controller;

class Request{
    public function __construct()
    {
        $authKey = request()->param()['token'];
        $uid = json_decode(decrypt($authKey, 'cxzxsxs'), true)['uid'];
        $cache = cache("CX_$uid");
        // 校验sessionid和authKey
        if (empty($authKey) || empty($cache) || !$cache || $cache != $authKey) {
            header('Content-Type:application/json; charset=utf-8');
            exit(json_encode(['code' => 104, 'data'=> "",'error' => '登录已失效']));
        }
    }
}